<layout name="Public/layout"/>
{:jumps($infos['authority'],CONTROLLER_NAME)}

        <!--主要区域开始-->
        <div id="main">
            
<!--            <form action="__SELF__" method="get" id="search">
                查询
                <div class="search_add">                        
                    <div>货号：<input type="text" class="width100 text_search"  value="{:I('get.sn')}" name='sn'/></div>
                    <div>商品名称：<input type="text" class="text_search" value="{:I('get.name')}" name='name'/></div>

<div>
                        类型：
                        <select class="select_search" name='category'>
                            <option value="">全部</option>
遍历类型                            
<volist name="category" id="vo">
                            <option value="{$vo.id}" <php> if( I('get.category')==$vo['id'] ){ echo 'selected';} </php>  >{$vo.name}</option>
</volist>                            
                            
                        </select>
</div>                    
                    
                    <div>
                        <input type="date" class="width120 text_search" name="month" value="{:I('get.month')}"/>
                        <php>
                            dump(strtotime( I('get.month') ) );
                        </php>
                    </div>
                    <div><input type="submit" value="搜索" class="btn_search" /></div>
                    <input type="button" value="销售记录" class="btn_add" onclick="location.href='sell_record.html';" />
                </div>  
            </form>    -->
                
            <form action="__SELF__" method="get" id="search">
                
                <!--查询-->
                <div class="search_add">                        
                    <div>货号：<input type="text" class="text_search width130" value="{:I('get.sn')}" name='sn'/></div>                            
                    <div>名称：<input type="text" class="width110 text_search" value="{:I('get.name')}" name='name'/></div>

<div>
                        排序：
                        <select class="select_search" name='order'>
                            <option value="id asc">默认</option>
                            <option value="price asc" <php> if( I('get.order')=='price asc' ){ echo 'selected';} </php> >  ↑ 价格从低到高 </option>                        
                            <option value="price desc" <php> if( I('get.order')=='price desc' ){ echo 'selected';} </php> > ↓ 价格从高到低 </option>
                            <option value="count asc" <php> if( I('get.order')=='count asc' ){ echo 'selected';} </php> >  ↑ 库存从低到高 </option>                        
                            <option value="count desc" <php> if( I('get.order')=='count desc' ){ echo 'selected';} </php> > ↓ 库存从高到低 </option> 
                            <option value="time asc" <php> if( I('get.order')=='time asc' ){ echo 'selected';} </php> >   ↑ 日期从低到高 </option>                        
                            <option value="time desc" <php> if( I('get.order')=='time desc' ){ echo 'selected';} </php> >  ↓ 日期从高到低 </option> 
                        </select>
</div>
                    
<div>
                        类型：
                        <select class="select_search" name='category'>
                            <option value="">全部</option>
<!--遍历类型-->                            
<volist name="category" id="vo">
                            <option value="{$vo.id}" <php> if( I('get.category')==$vo['id'] ){ echo 'selected';} </php>  >{$vo.name}</option>
</volist>                            
                            
                        </select>
</div>
                    
                    
                    <input type="button" value="销售记录" class="btn_add" onclick="location.href='__CONTROLLER__/record';" />
                    
                    <div style='margin:5px 0;display:block; '>
                        <div>
                            价格：<input type="text" class="width80 text_search" value="{:I('get.start_price')}" name='start_price'/>
                            -
                            <input type="text" class="width80 text_search" value="{:I('get.end_price')}" name='end_price'/>
                        </div>

<!--                        <div>
                            库存：<input type="text" class="width70 text_search" value="{:I('get.start_stock')}" name='start_stock'/>
                            -
                            <input type="text" class="width70 text_search" value="{:I('get.end_stock')}" name='end_stock'/>
                        </div>                        -->
                        
                        <div>
                            日期：<input type="date" class="width130 text_search" value="{:I('get.start_time')}" name='start_time'/>
                            -
                            <input type="date" class="width130 text_search" value="{:I('get.end_time')}" name='end_time'/>
                        </div>                            
                        
                    </div>
                      
                    
                </div>  
                
                <!--搜索开始-->
                    <div>
                        <input type="button" value="搜索" class="btn_search" id="btn_search" onclick="search()"/>
                        <button onclick="preview('data');" id="print">打印</button>
                    </div> 

                <!--搜索结束-->                
                
            </form> 


                <!--数据区域：用表格展示数据-->     
                <div id="data">            
                    <table id="datalist">
                    <tr>
                        <th class="width50">商品ID</th>
                        <th class="width70">货号</th>
                        <th>商品名称</th>
                        <th class="width100">类别</th>
                        <th class="width70">库存</th>
                        <th class="width50">单价</th>                 
                        <th class="width50"></th>
                    </tr>
<volist name="res['res']" id='vo' empty="$empty">                   
                    <tr>
                        <td>{$vo.id}</td>
                        <td>{$vo.sn}</td>
                        <td>{$vo.name}</td>
                        <td>{$vo.category_name}</td>
                        <td>{:array_sum( explode(',',$vo['count']) ); }</td>
                        <td>{$vo.price}</td>                   
                        <td><a href="__CONTROLLER__/item/id/{$vo.id}" title="账单明细">明细</a></td>
                    </tr>
</volist>                     

                </table>
                </div>                    
                <!--分页-->
                <div id="pages">
                    {$res['page']}
                </div>                    
            
        </div>
        <!--主要区域结束-->

<script type="text/javascript">
    $(function(){
        //点击之后的图标
        $('.sell_off').addClass('sell_on').removeClass('sell_off');

    });  

    function search(){
        layer.load(2); //加载
        setTimeout(function(){
            $('#search').submit();
        },{:C('SEARCH_TIME')});
        
    }
    
    $(function(){
        
        $('#status').change(function(){
            $('#search').submit();
        });
        
        $('select').change(function(){
            $('#search').submit();
        });        
    });
    
    //键盘事件    
    $(document).keydown(function(event){ 
        if(event.keyCode == 13){
//            alert(event.keyCode); 
            search();
        }            
                    
    });          
    
</script>
<script type="text/javascript">
       
       function preview(id){
           var sprnhtml=$('#'+id).html();   //获取区域内容
           var selfhtml=$('body').html(); //获取当前页的html
           $('body').html(sprnhtml);
           window.print();  //打印
           $('body').html(selfhtml); //赋值
       }
</script>